﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.Common;
using DHQGHN.DAL.DAO.Admin;
using DHQGHN.DAL.Models.Admin;

namespace DHQGHN.DAL.BO.Admin
{
    public class TechnicalLevelBO : BaseBO
    {
        public const string FIELD_TECHNICAL_LEVEL_ID = "TECHNICAL_LEVEL_ID";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        public const string Field_RECORD_COUNT = "RecordCount";

        private String _connectionString;

        public TechnicalLevelBO(string connString)
        {
            this._connectionString = connString;

        }
        public TechnicalLevelBO()
        {
            this._connectionString = Common.ConnectionUtil.TKTHDS_METADATA_CONNECTION_STRING;

        }

        public TechnicalLevelDAO _appDAO;

        public TechnicalLevelDAO CreateSQLDAO()
        {
            return new TechnicalLevelDAO(_connectionString, DEFAULT_MAPPER_TYPE);
        }

        public DataPage<TechnicalLevelModel> GetDynamicListPaging(TechnicalLevelModel aModel, int pageSize, int pageIndex,bool compareEqual)
        {
            try
            {
                _appDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {TechnicalLevelModel.FIELD_TECHNICAL_LEVEL_ID,FIELD_TECHNICAL_LEVEL_ID},
                    {TechnicalLevelModel.FIELD_NAME,FIELD_NAME},
                    {TechnicalLevelModel.FIELD_CODE,FIELD_CODE},  
                    {TechnicalLevelModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {TechnicalLevelModel.FIELD_DELETED,FIELD_DELETED},                    
                    {TechnicalLevelModel.FIELD_RECORD_COUNT,Field_RECORD_COUNT}
                    
                };
                return _appDAO.GetDynamicListPaging(aModel, pageSize, pageIndex, mapDictionary,compareEqual);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public DataPage<TechnicalLevelModel> GetDynamicListPagingd(TechnicalLevelModel aModel, int pageSize, int pageIndex, bool compareEqual)
        {
            try
            {
                _appDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {TechnicalLevelModel.FIELD_TECHNICAL_LEVEL_ID,FIELD_TECHNICAL_LEVEL_ID},
                    {TechnicalLevelModel.FIELD_NAME,FIELD_NAME},
                    {TechnicalLevelModel.FIELD_CODE,FIELD_CODE},  
                    {TechnicalLevelModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {TechnicalLevelModel.FIELD_DELETED,FIELD_DELETED},                    
                    {TechnicalLevelModel.FIELD_RECORD_COUNT,Field_RECORD_COUNT}
                    
                };
                return _appDAO.GetDynamicListPagingd(aModel, pageSize, pageIndex, mapDictionary, compareEqual);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public TechnicalLevelModel GetTechnicalLevelById(string appId)
        {
            try
            {
                _appDAO = CreateSQLDAO();

                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {TechnicalLevelModel.FIELD_TECHNICAL_LEVEL_ID,FIELD_TECHNICAL_LEVEL_ID},
                    {TechnicalLevelModel.FIELD_NAME,FIELD_NAME},
                    {TechnicalLevelModel.FIELD_CODE,FIELD_CODE},  
                    {TechnicalLevelModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {TechnicalLevelModel.FIELD_DELETED,FIELD_DELETED} 
                    
                };

                return _appDAO.GetById(appId, mapDictionary);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public bool createOrUpdateTechnicalLevel(TechnicalLevelModel appModel)
        {
            try
            {
                _appDAO = CreateSQLDAO();
                return _appDAO.createOrUpdateTechnicalLevel(appModel);
            }
            catch (Exception e)
            {
                return false;
            }
        }

        public bool deleteTechnicalLevel(string[] appId)
        {
            try
            {
                _appDAO = CreateSQLDAO();
                return _appDAO.deleteTechnicalLevel(appId);
            }
            catch (Exception e)
            {
                return false;
            }
        }

        public bool reActive(string appId)
        {
            try
            {
                _appDAO = CreateSQLDAO();
                return _appDAO.reActive(appId);
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }
}
